package com.hardydou.ide;


import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;

/**
 * 快捷键 ctrl+?
 * <p>
 * common+E,打开最近文件
 * commonl+J,快速打开帮助文档
 * ctrl+enter ,生成代码
 * ctrl+O ,覆盖方法
 * ctrl+I,实现接口方法
 * ctrl+R,运行程序
 * ctrl+D,调试程序
 * </p>
 * 快捷键 ctrl+alt+?
 * ctrl+alt+o，移除未使用 imports
 * ctrl+alt+I, 调整光标所在行缩进
 * ctrl+alt+R ,列出可执行菜单
 * ctrl+alt+H, 方法调用记录
 * alt+common+T ,sourred with
 *
 */
@RunWith(Parameterized.class)
public class KeyBoard  {
    private int year;
    private  int month;
    private int day;


    public KeyBoard(int year, int month, int day) {
        this.year=year;
        this.month=month;
        this.day=day;
    }

    @Test
    public void calWeek(){
        //cal object
        Calendar calendar = Calendar.getInstance();
        calendar.setFirstDayOfWeek(Calendar.MONDAY);
        calendar.set(year,month-1,day);
        System.out.println(calendar.getTime());
        System.out.println("calendar : "+ (calendar.get(Calendar.DAY_OF_WEEK)-1) );
        //蔡勒公式
        //w=(d+1+2m+3*(m+1)/5+y+y/4-y/100+y/400)%7
        int w = (day + 1 + 2 * month + 3 * (month + 1) / 5 + year + year / 4 - year / 100 + year / 400) % 7;
        System.out.println("蔡勒公式："+w);
        //（公元1年1日 到 日期 总天数）%7
       w= (365*(year-1)+(year-1)/4-(year-1)/100+(year-1)/400+calendar.get(Calendar.DAY_OF_YEAR))%7;
        System.out.println("累计天数%7 ： "+w);
    }

    @Parameterized.Parameters
    public static Collection<Object[]> data() {
        System.out.println("KeyBoard.data");
        Object[][] data={{2018,12,27},{2017,12,27},{2016,12,27},{1582,8,12}};
        return Arrays.asList(data);
    }


    @Before
    public void setUp() throws Exception {
        System.out.println("KeyBoard.setUp");
    }

    @After
    public void tearDown() throws Exception {
        System.out.println("KeyBoard.tearDown");
    }
}
